package com.elkovacho.view.mediators
{
	import com.elkovacho.view.components.CustomMouseCursor;
	
	import flash.events.MouseEvent;
	
	import org.robotlegs.mvcs.Mediator;
	
	public class CustomMouseCursorMediator extends Mediator
	{
		
		[Inject]
		public var view:CustomMouseCursor;
		
		override public function onRegister():void
		{
			eventMap.mapListener(contextView.stage, MouseEvent.MOUSE_MOVE, mouseMoveHandler, MouseEvent);
			eventMap.mapListener(view, MouseEvent.CLICK, mouseClickHandler, MouseEvent);
		}
		
		private function mouseMoveHandler(e:MouseEvent):void
		{
			view.updatePosition(e);
		}
		
		private function mouseClickHandler(e:MouseEvent):void
		{
			eventMap.unmapListener(contextView.stage, MouseEvent.MOUSE_MOVE, mouseMoveHandler, MouseEvent);
			
			view.click();
		}
		
	}
}